1、下载网址:MySQL :: Download MySQL Community Server
2、mySQL的配置文件
my.ini
3、命令提示符→以管理员身份运行
4、指令操作
4.1 初始化设置
C:\Users\rkwei>E:
E:\>cd mysql
E:\mysql>cd bin
E:\mysql\bin>mysqld --initialize --console
把密码复记下来,放入my.int文件内容:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录,需要手动修改
basedir=E:\mySQL
# 设置mysql数据库的数据的存放目录,需要手动修改
datadir=E:\mySQL\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
# 初始化后密码
wjALibtVQ5,2
如果忘记密码,可以删除data文件夹,重新初始化得到一个密码。
4.2 安装服务器:mysql8
E:\mysql\bin>mysqld --install mysql8
Service successfully installed.
4.3启停服务器 mysql8
E:\mysql\bin>net start mysql8
mysql8 服务正在启动 .
mysql8 服务已经启动成功。
E:\mysql\bin>net stop mysql8
mysql8 服务正在停止.
mysql8 服务已成功停止。
4.4 登录服务器
E:\mysql\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.3.0
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
4.5 修改密码
mysql> alter user root@'localhost' identified by '502';
Query OK, 0 rows affected (0.03 sec)
4.6 退出mysql
mysql> exit;
Bye
4.7 再次登录
可以在bin的目录下直接输入cmd 不需在管理员的状态下打开mysql
E:\mysql\bin>mysql -u root -p
Enter password: ***
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.3.0 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.